from settings import suites

from loguru import logger

import unittest

import os


def select_case_level(lst):
    if not isinstance(lst, list):
        logger.error(f'检测到传递的数据类型为{type(lst)}')
        return '要求传递的数据类型为列表'
    case_suites = []
    for a in lst:
        suite = unittest.TestLoader().discover('cases', f'*{a}.py')
        case_suites.extend(suite)
    return case_suites


def get_project_path():
    current_path = os.path.abspath(__file__)
    return current_path.split('utils')[0]


def get_log_path(filename):
    log_path = os.path.join(get_project_path(), 'logs')
    return os.path.join(log_path, filename)


if __name__ == '__main__':
    print(get_log_path('test.log'))
